import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:vmall_app/models/category.dart';

typedef OnCategoryClick =void Function(String name);

class HomeCategory extends StatelessWidget {
  final OnCategoryClick onCategoryClick;

  const HomeCategory({Key key, this.onCategoryClick}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    List<Widget> tabs = List();
    categoryList.forEach((item) {
      tabs.add(InkWell(
        child: Text(item.name,style: TextStyle(color: Colors.black),),
        onTap: () {
          if (this.onCategoryClick != null) {
            this.onCategoryClick(item.name);
          }
        },
      ));
      tabs.add(SizedBox(
        width: 10,
      ));
    });
    return ListView(
      physics: BouncingScrollPhysics(),
      scrollDirection: Axis.horizontal,
      dragStartBehavior: DragStartBehavior.start,
      children: tabs,
    );
  }
}
